home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 October / Macworld (1998-10).dmg / Shareware World / Info / For Developers / MacZoop 1.8.4 / More Classes / File Classes / ZFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-13  |  2.7 KB  |  128 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            MacZoop - "the framework for the rest of us"         
  5. *
  6. *
  7. *
  8. *            ZFile.h    -- a generic file object
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21.  
  22.  
  23. #pragma once
  24.  
  25. #ifndef __ZFILE__
  26. #define    __ZFILE__
  27.  
  28. #ifndef __ZCOMRADE__
  29. #include    "ZComrade.h"
  30. #endif
  31.  
  32. #include    <Files.h>
  33.  
  34. class    ZGWorld;
  35.  
  36. enum
  37. {
  38.     CLASS_ZFile        = 'zfil'
  39. };
  40.  
  41.  
  42. class    ZFile : public ZComrade
  43. {
  44. protected:
  45.  
  46.     short    refNum;            // data fork ref num when open
  47.     short    resRefNum;        // resource fork ref num when open
  48.     Boolean    isSafeSave;        // TRUE if this was a safe-save Write
  49.     OSType    itsType;        // file type
  50.     OSType    itsCreator;        // file creator- initialised to application creator type
  51.     FSSpec    itsSpec;        // file spec (name and location)
  52.     FSSpec    ssFSpec;        // temp file spec for safe-save
  53.     long    tempFID;        // temp folder ID
  54.     short    tempFVolID;        // temp folder volume
  55.     
  56. public:
  57.  
  58.     ZFile( const FSSpec& aSpec );
  59.     ZFile( Str255 fName );
  60.     ZFile();
  61.     ~ZFile();
  62.  
  63. // file opening and closing
  64.     virtual void    Open();
  65.     virtual void    Close();
  66.     virtual void    OpenSafe();
  67.  
  68. // creating/destroying a new file on disk    
  69.     virtual void    Create();
  70.     virtual void    Discard();
  71.  
  72. // accessing the resource fork    
  73.     virtual void    OpenResFork();
  74.     virtual void    CloseResFork();
  75.     virtual void    CreateResFork();
  76.     virtual void    SetResFork( short* curRes );
  77.  
  78. // reading and writing file data    
  79.     virtual void    Read( Ptr inBuffer, long* howMuch );
  80.     virtual void    Write( Ptr outBuffer, long* howMuch );
  81.     virtual void    Read( Handle aHandle );
  82.     virtual void    Write( Handle aHandle );
  83.  
  84. // file positioning and info    
  85.     virtual long    GetMark();
  86.     virtual void    SetMark( const long aMark );
  87.     
  88.     virtual OSType    GetType();
  89.     virtual void    SetType( const OSType aType );
  90.     virtual void    SetCreator( const OSType aCreator );
  91.  
  92.     virtual long    GetLength();
  93.     virtual void    SetLength( const long aLength );
  94.  
  95.     virtual void    GetFSSpec( FSSpec* aSpec );
  96.     virtual void    GetInfo( FInfo* fi );
  97.     virtual void    SetInfo( FInfo* fi );
  98.  
  99. // fork info    
  100.     virtual Boolean    HasResFork();
  101.     virtual Boolean    HasDataFork();
  102.  
  103. // disk file info    
  104.     virtual Boolean    IsReal();
  105.     virtual Boolean    IsLocked();
  106.     virtual Boolean    IsOpen();
  107.     
  108.     inline    short    GetRefNumber() { return refNum; };
  109.     inline    short    GetResourceRefNumber() { return resRefNum; };    
  110.     
  111. // making custom icons for the file:
  112.  
  113.     virtual void    MakeCustomIcon( PicHandle srcImage );
  114.     virtual void    MakeCustomIcon( ZGWorld* srcImage );
  115. protected:
  116.     
  117.     virtual void    InitFile();
  118.     virtual Handle    ConstructCustomIconSuite( PicHandle srcPic );
  119.     virtual void    SaveCustomIconSuite( Handle icnSuite );
  120.     
  121.     void            GetTempFolderID(); 
  122. };
  123.  
  124.  
  125. #define        _NOT_OPEN        -1
  126. #define        kUnknownType    '????'
  127.  
  128. #endif